<template>
	<view class="calc150 pl20 v100 pr20 overauto  bgcontain no-repeat"
		:style="{ backgroundImage: 'url(' + cosImageUrl('head_bg.png',true) + ')' }">
		<view class="" :style="{'paddingTop':statusBarHeigh + 'px',}">
			<!-- #ifdef H5 -->
			<view class="h60"></view>
			<!-- #endif -->
			<view class="flex alicen pl10" :style="{'height':menuButtonInfo.height + 'px',}">
				<u-icon name="arrow-left" color="#070707" size="18" @click="goback()"></u-icon>
				<view class="w40b"></view>
				<view class="fz30 bold">我的收藏</view>
			</view>
			<view class="pb30"></view>
			<view class="flex bgff000 fz28 colff  ltius10 ltius10  border1 boree" v-if="list&&list.length > 0">
				<view class="flex1 flexCenter pt20 pb20">序号</view>
				<view class="flex1 flexCenter pt20 pb20 bdl1-left1 boree">院校名称</view>
				<view class="flex1 flexCenter pt20 pb20 bdl1-left1 boree">专业组</view>
				<view class="flex1 flexCenter pt20 pb20 bdl1-left1 boree">专业</view>
				<view class="flex1 flexCenter pt20 pb20 bdl1-left1 boree">操作</view>
			</view>
			<view class="bgfff lbius10 rbius10 border1 boree" v-if="list&&list.length > 0">
				<view class="flex  fz24 col33  " v-for="(item,index) in list" :key="index">
					<view class="flex1 flexCenter pt20 pb20 bdl1-left1 boree txtcen">{{index + 1}}</view>
					<view class="flex1 flexCenter pt20 pb20 bdl1-left1 boree txtcen">{{item.schoolName}}</view>
					<view class="flex1 flexCenter pt20 pb20 bdl1-left1 boree txtcen">{{item.zyz}}</view>
					<view class="flex1 flexCenter pt20 pb20 bdl1-left1 boree txtcen">{{item.majorName||'--'}}</view>
					<view class="flex1 flexCenter pt20 pb20 bdl1-left1 boree col40" @tap.stop="delfavorite(item)">删除
					</view>
				</view>
			</view>
		</view>
		<u-empty v-if="list.length == 0" mode="list" text="收藏夹为空" size="28" ></u-empty>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [], //收藏的数组
			}
		},
		onLoad() {
			this.favorite();
		},
		methods: {
			async favorite() {
				let params = {
					userId: this.readData('useId')
				}
				let res = await this.request.get('/api/queryMyFavorite', {
					params
				})
				if (res.code == 200) {
					this.list = res.data
				}
			},
			//删除某个专业
			async delfavorite(item) {
				let params = {
					id: item.id,
					userId: this.readData('useId')
				}
				let delres = await this.request.get('/api/deleteMyFavorite', {
					params
				})
				if (delres.code == 200) {
					this.list = []
					this.successToShow(delres.msg || '删除成功', call => {
						this.favorite();
					})
				}
			}
		}
	}
</script>

<style lang="scss">
.calc150{height: calc(100vh - 150rpx)}
</style>